//
//  AIHomeWalletBtn.m
//  Mia
//
//  Created by Vill on 2024/1/10.
//

#import "AIHomeWalletBtn.h"

@interface AIHomeWalletBtn ()

@property (nonatomic, strong) UIImageView *iconImg;  //图标
@property (nonatomic, strong) UILabel *rightLbl;

@end

@implementation AIHomeWalletBtn

- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]){
        self.layer.cornerRadius = PTW(17);
        self.layer.masksToBounds = YES;
        self.backgroundColor = [UIColor colorHex:@"#333333" alpha:0.3];
        
        [self addSubview:self.iconImg];
        [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(PTW(26));
            make.leading.mas_equalTo(self).mas_offset(PTW(7));
            make.centerY.mas_equalTo(self);
        }];

        [self addSubview:self.rightLbl];
        [self.rightLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(self.iconImg.mas_trailing);
            make.trailing.mas_equalTo(self).mas_offset(-PTW(10));
            make.centerY.mas_equalTo(self);
        }];
    }
    return self;
}

- (UIImageView *)iconImg{
    if(!_iconImg){
        _iconImg = [UIImageView new];
        _iconImg.image = KImaged(@"ai_home_diamond");
    }
    return _iconImg;
}

- (UILabel *)rightLbl{
    if(!_rightLbl){
        _rightLbl = [UILabel new];
        _rightLbl.text = @"0";
        _rightLbl.textColor = UIColor.whiteColor;
        _rightLbl.font = [UIFont fontWithWeight:Medium size:PTW(20)];
        _rightLbl.textAlignment = NSTextAlignmentCenter;
    }
    return _rightLbl;
}

- (void)setWallet:(NSInteger)balance{
    self.rightLbl.text = [NSString stringWithFormat:@"%ld",balance];
    [self.rightLbl sizeToFit];
}

@end
